Merges from stable branch that had been left out. (#136282, J. Ali Harlow)
authorTor Lillqvist <tml@iki.fi>
Mon, 15 Mar 2004 13:07:04 +0000 (13:07 +0000)
committerTor Lillqvist <tml@src.gnome.org>
Mon, 15 Mar 2004 13:07:04 +0000 (13:07 +0000)
2004-03-15  Tor Lillqvist  <tml@iki.fi>

Merges from stable branch that had been left out. (#136282, J. Ali
Harlow)

Changes for run-time lookup of installation location on Win32:

* Makefile.am (INCLUDES): Define GTK_PREFIX as $(prefix).

* gdk-pixbuf-io.c (get_sysconfdir): New function, look up
installation location at runtime and deduce GTK_SYSCONFDIR
from it.
(get_toplevel): Similar, for the top-level installation directory.
(correct_prefix): Replace compile-time prefix with run-time
prefix.
(get_libdir): Remove, not used any longer.
(gdk_pixbuf_io_init): Call correct_prefix() on Win32.

* queryloaders.c (query_module): [Win32] Change backslahses into
slashes in path.

gdk-pixbuf/ChangeLog
gdk-pixbuf/Makefile.am
gdk-pixbuf/gdk-pixbuf-io.c
gdk-pixbuf/queryloaders.c

index 5382c771a1f6bf2f3a3fbc47a4fbc45ea886c427..7d2a06bef85d494b46a48173e0f41a28178eb3be 100644 (file)
@@ -1,3 +1,24 @@
+2004-03-15  Tor Lillqvist  <tml@iki.fi>
+
+       Merges from stable branch that had been left out. (#136282, J. Ali
+       Harlow)
+
+       Changes for run-time lookup of installation location on Win32:
+       
+       * Makefile.am (INCLUDES): Define GTK_PREFIX as $(prefix).
+
+       * gdk-pixbuf-io.c (get_sysconfdir): New function, look up
+       installation location at runtime and deduce GTK_SYSCONFDIR
+       from it.
+       (get_toplevel): Similar, for the top-level installation directory.
+       (correct_prefix): Replace compile-time prefix with run-time
+       prefix.
+       (get_libdir): Remove, not used any longer.
+       (gdk_pixbuf_io_init): Call correct_prefix() on Win32.
+
+       * queryloaders.c (query_module): [Win32] Change backslahses into
+       slashes in path.
+
 Tue Mar  9 09:33:28 2004  Owen Taylor  <otaylor@redhat.com>
 
        * === Released 2.3.6 ===
index 9b1d5b512f814b45d4a611da2bdb754e46da8d3a..562a53e40b6f2cf294d61c4f80791287f305ccd1 100644 (file)
@@ -261,6 +261,7 @@ INCLUDES = \
        -DGTK_BINARY_VERSION=\"$(GTK_BINARY_VERSION)\"  \
        -DG_DISABLE_DEPRECATED                  \
        -DGDK_PIXBUF_DISABLE_DEPRECATED         \
+       -DGTK_PREFIX=\"$(prefix)\"              \
        $(INCLUDED_LOADER_DEFINE)               \
        $(GTK_DEBUG_FLAGS)                      \
        $(GDK_PIXBUF_DEP_CFLAGS)                \
index 92ddb55b682539a2cdbb126dc339a824f9e4f7ff..b916421d05d1e4de11c80356dd16a8a232303276 100644 (file)
@@ -170,6 +170,59 @@ skip_space (const char **pos)
        return !(*p == '\0');
 }
   
+#ifdef G_OS_WIN32
+
+/* DllMain function needed to tuck away the gdk-pixbuf DLL name */
+G_WIN32_DLLMAIN_FOR_DLL_NAME (static, dll_name)
+
+static char *
+get_toplevel (void)
+{
+  static char *toplevel = NULL;
+
+  if (toplevel == NULL)
+    toplevel = g_win32_get_package_installation_subdirectory
+      (GETTEXT_PACKAGE, dll_name, "");
+
+  return toplevel;
+}
+
+static char *
+get_sysconfdir (void)
+{
+  static char *sysconfdir = NULL;
+
+  if (sysconfdir == NULL)
+    sysconfdir = g_win32_get_package_installation_subdirectory
+      (GETTEXT_PACKAGE, dll_name, "etc");
+
+  return sysconfdir;
+}
+
+#undef GTK_SYSCONFDIR
+#define GTK_SYSCONFDIR get_sysconfdir()
+
+static void
+correct_prefix (gchar **path)
+{
+  if (strncmp (*path, GTK_PREFIX "/", strlen (GTK_PREFIX "/")) == 0 ||
+      strncmp (*path, GTK_PREFIX "\\", strlen (GTK_PREFIX "\\")) == 0)
+    {
+      /* This is an entry put there by gdk-pixbuf-query-loaders on the
+       * packager's system. On Windows a prebuilt GTK+ package can be
+       * installed in a random location. The gdk-pixbuf.loaders file
+       * distributed in such a package contains paths from the package
+       * builder's machine. Replace the build-time prefix with the
+       * installation prefix on this machine.
+       */
+      gchar *tem = *path;
+      *path = g_strconcat (get_toplevel (), tem + strlen (GTK_PREFIX), NULL);
+      g_free (tem);
+    }
+}
+
+#endif
+
 static gchar *
 gdk_pixbuf_get_module_file (void)
 {
@@ -214,6 +267,9 @@ gdk_pixbuf_io_init ()
                                /* Blank line marking the end of a module
                                 */
                        if (module && *p != '#') {
+#ifdef G_OS_WIN32
+                               correct_prefix (&module->module_path);
+#endif
                                file_formats = g_slist_prepend (file_formats, module);
                                module = NULL;
                        }
@@ -336,29 +392,6 @@ gdk_pixbuf_io_init ()
        g_free (filename);
 }
 
-#ifdef G_OS_WIN32
-
-/* DllMain function needed to tuck away the gdk-pixbuf DLL name */
-
-G_WIN32_DLLMAIN_FOR_DLL_NAME (static, dll_name)
-
-static char *
-get_libdir (void)
-{
-  static char *libdir = NULL;
-
-  if (libdir == NULL)
-    libdir = g_win32_get_package_installation_subdirectory
-      (GETTEXT_PACKAGE, dll_name, "lib\\gtk-2.0\\" GTK_BINARY_VERSION "\\loaders");
-
-  return libdir;
-}
-
-#undef PIXBUF_LIBDIR
-#define PIXBUF_LIBDIR get_libdir ()
-
-#endif
-
 /* actually load the image handler - gdk_pixbuf_get_module only get a */
 /* reference to the module to load, it doesn't actually load it       */
 /* perhaps these actions should be combined in one function           */
index f5428f30dad0d179899e5f0d9da2270979f73219..e2f6bfc91035b310372cf4cd9da0a09e02f3aaf5 100644 (file)
@@ -162,6 +162,19 @@ query_module (const char *dir, const char *file)
                GdkPixbufFormat *info;
                GdkPixbufModule *vtable;
                
+#ifdef G_OS_WIN32
+               /* Replace backslashes in path with forward slashes, so that
+                * it reads in without problems.
+                */
+               {
+                       char *p = path;
+                       while (*p) {
+                               if (*p == '\\')
+                                       *p = '/';
+                               p++;
+                       }
+               }
+#endif 
                info = g_new0 (GdkPixbufFormat, 1);
                vtable = g_new0 (GdkPixbufModule, 1);